#ifndef __VERTEXBUFFEROBJECT_H__
#define __VERTEXBUFFEROBJECT_H__

//#include <GL/glew.h>
//#include <GL/gl.h>

class VertexBufferObject
{
	GLuint _handle;
	GLenum _target;
	
public:

	VertexBufferObject(GLenum _Target=GL_ARRAY_BUFFER_ARB) : _target(_Target) { glGenBuffers(1, &_handle); bind(_target); }
	~VertexBufferObject() { glDeleteBuffersARB(1, &_handle); }
	const GLuint& getHandle() const { return _handle; }
	const GLenum& getTarget() const { return _target; }
	void bind() { glBindBufferARB(_target, _handle); }
	void bind(const GLenum _Target) { glBindBufferARB(_Target, _handle); }
	void unbind() { glBindBufferARB(_target, 0); }
	void unbind(const GLenum _Target) { glBindBufferARB(_Target, 0); }
//	(void*) mapBuffer(GLenum _Access=GL_WRITE_ONLY_ARB) { return glMapBufferARB(_target, _Access); }
	void unmapBuffer() { glUnmapBufferARB(_target); }

};

#endif




/*
	VertexBufferObject(const void* data, int dataSize, GLenum target, GLenum usage)
	{
		if( glewIsSupported( "GL_ARB_vertex_handle_object" ) )
		{
			glGenBuffers(1, &_handle);
			init( data, dataSize, target, usage );
		}
	}

	void init(const void* data, int dataSize, GLenum target, GLenum usage)
	{
		glBindBufferARB(target, _handle);                    // activate vbo id to use
		glBufferDataARB(target, dataSize, data, usage); // upload data to video card

		// check data size in VBO is same as input array, if not return 0 and delete VBO
		int bufferSize = 0;
		glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &bufferSize);
		if(dataSize != bufferSize)
		{
			glDeleteBuffersARB(1, &_handle);
			_handle = 0;
			cout << "[createVBO()] Data size is mismatch with input array\n";
		}
	}
*/
